-
Notifications
You must be signed in to change notification settings - Fork 985
Add custom ExchangeId generator support #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| /** | ||
| * @since 5.1 | ||
| */ | ||
| public void setExchangeId(final String exchangeId) { | ||
| this.exchangeId = exchangeId; | ||
| } | ||
|
|
||
| /** | ||
| * @since 5.7 | ||
| */ | ||
| public String setExchangeId(final Supplier<String> supplier) { | ||
| final String exchangeId = this.exchangeId; // avoid getfield opcode | ||
| if (exchangeId == null) { | ||
| return this.exchangeId = supplier.get(); | ||
| } else { | ||
| return exchangeId; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks incoherent. I'd expect the client builders to simply take a Supplier<String> exchangeIdSupplier, which defaults to ExecSupport::getNextExchangeId. The context classes shouldn't need to know about what supplies the exchange IDs, they should just know the exchange ID for the particular exchange they represent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there should be a documented contract for custom exchange ID suppliers, i.e. they must return a unique, non-null, non-blank string every time they are called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll refactor the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rschmitt I've implemented the changes as discussed. The ExchangeIdGenerator interface has been added to allow custom exchange ID generation. Please review when convenient. Thank you!
d6326b4 to
5069736
Compare
Add ExchangeIdGenerator interface to allow users to customize exchange ID generation in HTTP clients.
This change introduces the ExchangeIdGenerator interface, which enables users to provide custom strategies for generating exchange identifiers. This is particularly useful in distributed systems where custom tracing and correlation mechanisms are required.